<template>
  <div>
    <div>测试动画</div>
    <button @click='toggle'>点击</button>
    <transition name="fade">
      <div v-if='isShow'>动画</div>
    </transition>
  </div>
</template>
<script>
import { ref } from 'vue'
export default {
  setup () {
    const isShow = ref(false)
    const toggle = () => {
      isShow.value = !isShow.value
    }
    return { isShow, toggle }
  }
}
</script>
<style scoped>
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.fade-enter-active,
.fade-leave-active {
  transition: all 1s;
}

.fade-enter-to,
.fade-leave-from {
  opacity: 1;
}
</style>
